package rad.framework.mda.generator.template.main.java.sample;

import org.eclipse.uml2.uml.Enumeration;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.*;
import java.util.*;
import rad.framework.mda.generator.util.*;
import org.eclipse.emf.codegen.util.*;

public class SampleGen
{
  protected static String nl;
  public static synchronized SampleGen create(String lineSeparator)
  {
    nl = lineSeparator;
    SampleGen result = new SampleGen();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "";
  protected final String TEXT_2 = "/*" + NL + " * ============================================================================" + NL + " *                   GNU Lesser General Public License" + NL + " * ============================================================================" + NL + " */";
  protected final String TEXT_3 = NL + "package ";
  protected final String TEXT_4 = ";";
  protected final String TEXT_5 = NL;
  protected final String TEXT_6 = NL + NL + "/**" + NL + " * ";
  protected final String TEXT_7 = NL + " *" + NL + " * @author ";
  protected final String TEXT_8 = NL + " * @generated" + NL + " */" + NL + "@Name(\"";
  protected final String TEXT_9 = "Init\")" + NL + "@Scope(ScopeType.APPLICATION)" + NL + "public class ";
  protected final String TEXT_10 = "Init implements Serializable {" + NL + "" + NL + "\t/** @generated */" + NL + "\t@Logger" + NL + "\tprivate Log log;" + NL + "" + NL + "\t/** @generated */" + NL + "\t@Observer(\"org.jboss.seam.postInitialization\")" + NL + "\tpublic void init() throws Exception {" + NL + "\t\tlog.info(\"Starting ";
  protected final String TEXT_11 = "Init...\");" + NL + "\t}" + NL + "}";
  protected final String TEXT_12 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    Model uml2Package = (Model) argument;
    stringBuffer.append(TEXT_1);
    stringBuffer.append(TEXT_2);
    ImportManager importManager=null;
    if (NameHelper.getQualifiedName(uml2Package) != null) {
    importManager = ImportHelper.makeImportManager(NameHelper.getQualifiedName(uml2Package));
    stringBuffer.append(TEXT_3);
    stringBuffer.append(NameHelper.getQualifiedName(uml2Package));
    stringBuffer.append(TEXT_4);
    } else {
    importManager = ImportHelper.makeImportManager("");
    }
    importManager.addImport("java.io.Serializable");
    importManager.addImport("org.jboss.seam.ScopeType");
    importManager.addImport("org.jboss.seam.annotations.Logger");
    importManager.addImport("org.jboss.seam.annotations.Name");
    importManager.addImport("org.jboss.seam.annotations.Observer");
    importManager.addImport("org.jboss.seam.annotations.Scope");
    importManager.addImport("org.jboss.seam.log.Log");
    stringBuffer.append(TEXT_5);
    
StringBuffer importStringBuffer = stringBuffer;
int importInsertionPoint = stringBuffer.length();
importManager.addCompilationUnitImports(stringBuffer.toString());

    stringBuffer.append(TEXT_6);
    stringBuffer.append(TypeHelper.getDocumentation(uml2Package));
    stringBuffer.append(TEXT_7);
    stringBuffer.append(System.getProperty("user.name"));
    stringBuffer.append(TEXT_8);
    stringBuffer.append(NameHelper.getUncapName(uml2Package));
    stringBuffer.append(TEXT_9);
    stringBuffer.append(NameHelper.getCapName(uml2Package));
    stringBuffer.append(TEXT_10);
    stringBuffer.append(NameHelper.getCapName(uml2Package));
    stringBuffer.append(TEXT_11);
    importStringBuffer.insert(importInsertionPoint, importManager.computeSortedImports());
    stringBuffer.append(TEXT_12);
    return stringBuffer.toString();
  }
}
